import Vue from "vue";
import Router from "vue-router";
import menuRouter from "./config"; //菜单配置

Vue.use(Router);
const router = new Router({
    routes: [
        {
            path: "/",
            redirect: "/login"
        },
        {
            path: "/login",
            name: "登录",
            component: resolve => require(["../views/Login.vue"], resolve)
        },
        {
            path: "/Home",
            name: "首页",
            redirect: "/Welcome",
            component: resolve => require(["../components/Home.vue"], resolve),
            children: [
                {
                    path: "/Welcome",
                    name: "欢迎",
                    component: resolve =>
                        require(["../views/Welcome.vue"], resolve)
                }
            ]
        },
        ...menuRouter,
        {
            path: "*",
            name: "404",
            component: resolve => require(["../views/404.vue"], resolve)
        }
    ]
});

router.beforeEach((to, from, next) => {
    next();
});

router.afterEach(transition => {});
export default router;
